package models;

import java.util.Date;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import play.data.validation.MaxSize;
import play.data.validation.MinSize;
import play.data.validation.Required;
import play.db.jpa.Model;

/**
 * Article模块::一个简单的文章管理模块，继承NormalModel
 * 
 * @see BaseModule
 * @see NormalModel
 * @since 1.0
 * @author Mr.J.
 * **/
@Entity
public class Article extends NormalModel implements BaseModule{
//	@MaxSize(message="title must more than '15' length",value=15)
	@Required(message="title must be required")
	public String title;
	
//	@MaxSize(message="introduce must more than '30' length",value=30)
	@Required(message="introduce must be required")
	public String introduce;
	
	public String ImageURL;
	
	@ManyToOne
	public User user;
	
	@Lob
	@Basic(fetch=FetchType.LAZY,optional=false)
	@Required(message="content must be required")
	public String content;

	public Article(String title, String introduce, String content) {
		super();
		this.title = title;
		this.introduce = introduce;
		this.content = content;
	}
	
	public Article(String title, String introduce, String content, User user) {
		super();
		this.title = title;
		this.introduce = introduce;
		this.content = content;
		this.user = user;
		this.createDate = new Date();
	}
}
